package timer;

import java.util.Date;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @author ml
 * @create 2017-11-06--16:19
 */
public class ScheduleExecutorServiceDemo implements Runnable {
    @Override
    public void run() {
        System.out.println("执行时间:"+new Date()+Thread.currentThread().getName());

    }

    public static void main(String[] args) {
        ScheduledExecutorService scheduledExecutorService= Executors.newScheduledThreadPool(10);
        scheduledExecutorService.scheduleAtFixedRate(new ScheduleExecutorServiceDemo(),1000,2000, TimeUnit.MILLISECONDS);
    }

}
